<nz-card>
  <div class="opera-btns">
    <button nz-button nzType="primary" (click)="showModal(0)">
      <i nz-icon nzType="plus" nzTheme="outline"></i>
      新增热搜
    </button>
  </div>

  <div class="pagination-wrap-position">
    <div class="table-wrap p-t-15">
      <nz-table
        #basicTable
        nzSize="small"
        nzShowSizeChanger
        nzShowQuickJumper
        nzOuterBordered
        [nzFrontPagination]="false"
        [nzLoadingDelay]="100"
        [nzLoading]="tableParams.tableLoading"
        [nzData]="tableData"
        [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
        [nzTotal]="tableParams.total"
        [nzPageIndex]="tableParams.page"
        [nzPageSize]="tableParams.pageSize"
        [nzShowTotal]="totalTemplate"
        (nzPageIndexChange)="onPageIndexChange($event)"
        (nzPageSizeChange)="onPageSizeChange($event)"
      >
        <thead>
          <tr>
            <th nzAlign="center" nzWidth="120px">排序</th>
            <th nzAlign="center">机型名称</th>
            <th nzAlign="center">更新时间</th>
            <th nzAlign="center">操作</th>
          </tr>
        </thead>

        <tbody>
          <tr *ngFor="let data of basicTable.data; let index = index;">
            <td nzAlign="center">{{ index + 1 }}</td>
            <td nzAlign="center">{{ data.modelName || '-' }}</td>
            <td nzAlign="center">{{ data.updateTime || '-' }}</td>
            <!-- 操作 -->
            <td nzAlign="center">
              <button nz-button nzType="link" [disabled]="index == 0" (click)="sortTable(1, data.id)">上移</button>
              <button nz-button nzType="link" [disabled]="index == tableData.length - 1" (click)="sortTable(2, data.id)">下移</button>
              <button nz-button nzType="link" (click)="showModal(1, data)">编辑</button>
              <a
                nz-button
                nzType="link"
                nzDanger
                nz-popconfirm
                nzPopconfirmTitle="确认删除?"
                [nzIcon]="iconTpl"
                (nzOnConfirm)="deleteItem(data)">
                删除
              </a>
              <ng-template #iconTpl>
                <i nz-icon nzType="question-circle-o" style="color: red;"></i>
              </ng-template>
            </td>
          </tr>
        </tbody>
      </nz-table>

      <!-- 分页template -->
      <ng-template #totalTemplate let-total>共有 {{ tableParams.total }} 条</ng-template>
    </div>
  </div>
</nz-card>

<!-- 新增编辑 Modal START -->
<nz-modal
  nzClassName="custom-model-wrap"
  [nzFooter]="null"
  [(nzVisible)]="isVisible"
  [nzTitle]="modalType == 0 ? '新增热搜' : '编辑热搜'"
  (nzOnCancel)="handleCancel()">

  <div *nzModalContent>
    <div class="custom-model-body">
      <!-- body START -->
      <form nz-form class="modal-body" [formGroup]="validateForm">
        <nz-form-item>
          <nz-form-label nzSpan="6" nzRequired>机型名称</nz-form-label>
          <nz-form-control nzSpan="18" nzErrorTip="请选择机型!">
            <nz-select
              nzShowSearch
              nzAllowClear
              nzServerSearch
              nzPlaceHolder="请输入机型名称"
              [nzShowArrow]="false"
              [nzFilterOption]="nzFilterOption"
              formControlName="modelId"
              (nzOnSearch)="searchModel($event)">
              <ng-container *ngFor="let o of getModelEvalOptions">
                <nz-option *ngIf="!isInputLoading" [nzLabel]="o?.name" [nzValue]="o?.id"></nz-option>
              </ng-container>
              <nz-option *ngIf="isInputLoading" nzDisabled nzCustomContent>
                <i nz-icon nzType="loading" class="loading-icon"></i>
                数据加载中...
              </nz-option>
            </nz-select>
          </nz-form-control>
        </nz-form-item>
      </form>
      <!-- body END -->
    </div>

    <div class="custom-model-foot">
      <div class="custom-foot-cont">
        <button nz-button nzType="primary" [nzLoading]="subModalLoding" (click)="submitForm()">确定</button>
        <button nz-button nzType="default" (click)="handleCancel()">取消</button>
      </div>
    </div>
  </div>
</nz-modal>
<!-- 新增编辑 Modal END -->